package com.patrol.patrol.ui.route;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.patrol.patrol.R;

import java.util.List;

public class NestRouteAdapter extends RecyclerView.Adapter<NestRouteAdapter.NestRouteViewHolder>{

    List<Route> titles;
    Context context;
    int currentPosition = 0;

    public NestRouteAdapter(List<Route> titles, Context context) {
        this.titles = titles;
        this.context = context;
    }

    public void setCurrentPosition(int currentPosition) {
        this.currentPosition = currentPosition;
    }

    @NonNull
    @Override
    public NestRouteViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_detail_1, parent, false);
        return new NestRouteViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull NestRouteViewHolder holder, int position) {
        holder.tv_detail_name.setText(titles.get(currentPosition).getSubTitles().get(position));
    }

    @Override
    public int getItemCount() {
        return titles.get(currentPosition).getSubTitles().size();
    }

    class NestRouteViewHolder extends RecyclerView.ViewHolder{

        TextView tv_detail_name;
        RadioGroup rg_item;
        public NestRouteViewHolder(@NonNull View itemView) {
            super(itemView);
            tv_detail_name = itemView.findViewById(R.id.tv_detail_name);
            rg_item = itemView.findViewById(R.id.rg_item);
        }
    }
}
